let form = layui.form

form.verify({
  len: [/^\S{6,12}$/, '长度不一致'],

  diff: function (val) {
    if ($('.diff').val() === val) {
      return '不能跟原密码一致'
    }
  },
  same: function (res) {
    if (res !== $('.same').val()) {
      return '两次密码不一致'
    }
  }
})

$('form').on('submit', function (e) {
  e.preventDefault()
  $.ajax({
    type: 'POST',
    url: '/my/user/updatepwd',
    data: $(this).serialize(),
    success: function (res) {
      console.log(res)
      if (res.status === 0) {
        localStorage.removeItem('token')
        window.parent.location.href = '../login.html'
      }
    }

  })
})